import { createStore, Store, useStore as useVuexStore } from 'vuex'
import login from './login'
import { IRootState, IStore } from './types'

export default createStore<IRootState>({
  state: {},
  mutations: {},
  actions: {},
  modules: { login }
})

// 此时使用此处的useStore就会按照严格的类型控制
// Store 传入的泛型就是真正的 rootState 的类型
export const useStore = (): Store<IStore> => {
  return useVuexStore()
}
